home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_c / lsdoor09.zip / EXAMPLE3.CPP < prev    next >
Text File  |  1996-05-15  |  2KB  |  62 lines

  1. // Example3.Cpp - Sending a Commlink (Page)...
  2.  
  3. #define MainModule
  4. #include "LsDoor.H"
  5.  
  6. char *errorModule( void ){ return "Example3 Commlinks"; }
  7.  
  8.  
  9. void main( void )
  10. {
  11.   if( !DoorInit( doorsysDISABLE ) ) exit(1);      // Get things started...
  12.   // If you just need to send a page, call the PageUser() function and you're
  13.   // done.
  14.   PageUser();
  15.  
  16.   int oldRead = read_commlinks;
  17.   read_commlinks = 0;   // Don't want an incoming to erase our workspace...
  18.  
  19.   // If you need to communicate with another node, you can setup a custom
  20.   // CommLink type, BUT contact LightSpeed HQ before you do this in any
  21.   // public program.  You will have a unique ID number given for your program
  22.   // free of charge.
  23.  
  24.   commlink.type = 1;    // This will be where your unique ID goes.  Type 1
  25.                         // is the regular pager.  Types 0 to 30 are reserved.
  26.   commlink.link = 0;
  27.   strcpy( commlink.from, user.handle );
  28.   strcpy( commlink.data, "You can send whatever you need here" );
  29.     // The commlink.data is a char string of 160 bytes.  You can put whatever
  30.     // data you need here.  For type 1 (User to user pages) this contains the
  31.     // text from the page.
  32.  
  33.     // node.ID.num provides the current node's number, except that the first
  34.     // first node is always number 0.  save_commlink() also requires a
  35.     // start-at-0 node number.
  36.  
  37.   int bestNode = node.ID.num + 3;     // bestNode = 'This Node #' + 3
  38.  
  39.   /*  You could use this method if you needed to find someone by name:
  40.   if( (bestNode=FindUserOnline("UsersHandle")) == -1 ){
  41.     display("\n@CU@cser not found...");
  42.     read_commlinks = save_rdcomm;
  43.     return;
  44.   }
  45.   */
  46.  
  47.   save_commlink( bestNode );   // save_commlinks() also uses start-at-0 node#
  48.   read_commlinks = oldRead;
  49.   display("\n@1...@WS@went just fine..." );
  50.   display(
  51.     "\n\n@CPlease note that the results of this example will not be apparant"
  52.     "\nunless you are running other LightSpeed nodes which can receive the"
  53.     "\npages sent from this example."
  54.  
  55.   exit(0);                                        // Always use exit()
  56. }
  57.  
  58. // End of Example3.Cpp
  59.  
  60.  
  61.  
  62.